package com.wuzhun.wxmp.controller.admin;

import com.wuzhun.wxmp.annotation.PageLoginRequired;
import com.wuzhun.wxmp.controller.BaseController;
import com.wuzhun.wxmp.service.IAdminUserService;
import com.wuzhun.wxmp.service.IMessageService;
import com.wuzhun.wxmp.service.IWechatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * 后台首页控制器
 *
 * @author : renbaolin
 * @date : 2022/12/28 7:54 下午
 */
@Controller
@RequestMapping("/admin/home")
@Api("后台首页")
public class AdminHomeController extends BaseController {

    @Resource
    private IWechatService wechatService;
    @Resource
    private IMessageService messageService;
    @Resource
    private IAdminUserService adminUserService;

    @GetMapping("")
    @ApiOperation("后台框架首页")
    @PageLoginRequired
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("wechatNumber", wechatService.count());
        modelAndView.addObject("messageNumber", messageService.count());
        modelAndView.addObject("userNumber", adminUserService.count());
        return commonView(modelAndView, "admin/home/index");
    }
}
